@extends("admin.layout.main")

@section("content")
    <?php $role = Session::get('authModule');?>
    <!--主页面头部信息-->
    <div class="page-header">
        <h1>
            创客管理
        </h1>
    </div>
    <!-- /.page-header -->

    <div class="page-header">
        <form method="get" action="">
            <a class="btn btn-xs btn-success" onclick="doExport()">
                导出会员
            </a>
            <label style="float: right">
                <select name="type">
                    <option value="1" @if($where['type']==1) selected @endif>手机号码</option>
                    <option value="2" @if($where['type']==2) selected @endif>创客ID</option>
                </select>
                <input type="text" name="keyword" id="keyword" value="{{ $where['keyword'] }}">
                <button class="btn btn-xs btn-primary" style="margin-top:-4px;">搜索</button>
            </label>
        </form>
    </div>
    <div class="row">
        <div class="col-xs-12">
            <table id="simple-table" class="table  table-bordered table-hover" style="text-align: center;">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>创客昵称</th>
                    <th>手机号码</th>
                    <th>创客类别</th>
                    <th>总业绩</th>
                    <th>积分</th>
                    <th>待结算积分</th>
                    <th>注册币</th>
                    <th>待结算注册币</th>
                    <th>注册时间</th>
                    <th>复消日期</th>
                    <th>操作</th>
                </tr>
                </thead>

                <tbody>
                @foreach($data as $v)
                    <tr>
                        <td>{{ $v->id }}</td>
                        <td>{{ $v->name }}</td>
                        <td>{{ $v->mobile }}</td>
                        <td>@if($v->user_type==1)创客 @else 城市合伙人@endif</td>
                        <td>{{ $v->entrepreneurship_achievement+$v->chuangheng_achievement+$v->director_achievement }}</td>
                        <td>{{ $v->integral }}</td>
                        <td>{{ $v->freeze_integral }}</td>
                        <td>{{ $v->registered_currency }}</td>
                        <td>{{ $v->freeze_registered_currency }}</td>
                        <td>{{ $v->created_at }}</td>
                        <td>{{ $v->repeated_consumption_date }}</td>
                        <td>
                            <a class="btn btn-xs btn-primary" href="{{ route('admin.member.view',['id'=>$v->id]) }}">详情</a>
                            <a class="btn btn-xs btn-pink" href="{{ route('admin.member.recommend',['id'=>$v->id]) }}">推荐关系</a>
                            <a class="btn btn-xs btn-info2" href="{{ route('admin.member.cash',['id'=>$v->id]) }}">资金</a>
                             @if($v->user_renew ==1 && $v->repeated_consumption_date)
                            <a class="btn btn-xs btn-yellow" data-id="{{ $v->id }}" onclick="confirm_handle('确认给{{ $v->name }}增加一个月复消时间?',resale,'',this)">复消</a>
                            @endif
                            @if($v->user_type==1)
                            <a class="btn btn-xs btn-success" data-id="{{ $v->id }}" onclick="confirm_handle('确认将{{ $v->name }}设为合伙人?',setCompany,'',this)">设为合伙人</a>
                            @endif
                            @if($v->status==2 || $v->status==3)
                                <a class="btn btn-xs btn-info" data-id="{{ $v->id }}" data-status="1" onclick="confirm_handle('确认启用{{ $v->name }}?',changeStatus,'',this)">启用</a>
                            @else
                                <a class="btn btn-xs btn-danger" data-id="{{ $v->id }}" data-status="2" onclick="confirm_handle('确认停用{{ $v->name }}?',changeStatus,'',this)">禁用</a>
                            @endif
                            {{--@if($v->user_type==1)--}}
                                <a class="btn btn-xs btn-purple" href="{{ route('admin.member.transferCoin',['id'=>$v->id]) }}">转账</a>
                            {{--@endif--}}
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
            {{ $data->appends($where)->links('admin.layout.page') }}
        </div>
    </div>
    <script src="{{ config('global.assets_path') }}js/jquery.validate.min.js"></script>
    <script src="{{ config('global.assets_path') }}js/messages_zh.js"></script>
    <script src="/plugins/layui/layui.js"></script>
    <script src="/plugins/layui/layui_component.js"></script>
    <script src="/js/ajax.js"></script>
    <script>
        function changeStatus(obj) {
            var id = $(obj).data('id');
            var status = $(obj).data('status');
            var data = {'id': id, 'status': status};
            ajaxRequest(data, "{{route('admin.member.changeUserStatus')}}", 'POST')
        }

        function resale(obj) {
            var id = $(obj).data('id');
            var data = {'id':id,'user_renew':1};
            ajaxRequest(data,'{{ route('admin.member.changeUserStatus') }}','POST');
        }

        function setCompany(obj){
            var id = $(obj).data('id');
            var data = {'id':id,'user_type':2};
            ajaxRequest(data,'{{ route('admin.member.changeUserStatus') }}','POST');
        }

        //导入excel
        function doExport() {
            var theurl = "{{ url('admin/member/export') }}?keyword={{ $where['keyword'] }}";
            window.open(theurl);
        }
    </script>
@endsection
